package org.jeecg.modules.fk.core.rest.response;

import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import org.jeecg.modules.fk.core.rest.RestResponse;
import org.jeecg.modules.fk.core.rest.RestResponseHead;

import java.util.Collections;
import java.util.Map;


public class OneKeyResponse<V> {
    protected Map<String, Object> oneKeyMap = Collections.emptyMap();

    public OneKeyResponse() {
    }

    public void singleton(String key, V value) {
        this.oneKeyMap = Collections.singletonMap(key, value);
    }

    @JsonAnyGetter
    public Map<String, Object> getProperties() {
        return this.oneKeyMap;
    }

    public static void main(String[] args) {
        RestResponse<LongResponse> goodsId = RestResponse.create("goodsId", 9223372036854775807L);
        RestResponseHead head = new RestResponseHead();
        head.setGtime(System.currentTimeMillis());
        goodsId.setHead(head);
        System.out.println(JSONUtil.toJsonStr(goodsId));
    }
}
